import popMessage from "@/utils/popMessage";


const tx_key_ip="VBABZ-YDOC5-QDGIA-QMJVG-DHSY5-7TBWV";  //这个key就是你申请的密钥
    // let output="jsonp";
const tx_api_ip ="https://apis.map.qq.com/ws/location/v1/ip"; //这个就是地理位置信息的接口
export default {
    watch: {

    },
    beforeMount() {

    },
    mounted() {

    },
    methods: {
        getLoaction(callback)
        {

            this.$jsonp(tx_api_ip, Object.assign({key:tx_key_ip},{output:"jsonp"}))
                .then(res => {
                    // this.ip1=res;
                    // console.log(res)
                    let data=res.result;
                    let nation=data.ad_info.nation;
                    let province=data.ad_info.province;
                    let city=data.ad_info.city;
                    // return nation+"-"+province+"-"+city;
                    callback(nation+"-"+province+"-"+city)
                    // this.MyLocation=nation+"-"+province+"-"+city;
                    /*localStorage.setItem("Location",this.MyLocation);*/
                })
                .catch(error => {
                    // this.ip1=error;
                    // console.log(error);
                    popMessage(true,"获取当前位置失败","error");
                });
        },

    }
}
